<?php

namespace app\common\model;

/**
 * 用户收货地址模型
 * Class UserAddress
 * @package app\common\model
 */
class People extends BaseModel
{
    protected $name = 'people';


    /**
     * 关联商品图片表
     * @return \think\model\relation\HasMany
     */
    public function image()
    {
        return $this->hasMany('PeopleImage')->order(['id' => 'asc']);
    }


    /**
     * 地区名称
     * @param $value
     * @param $data
     * @return array
     */
    public function getRegionAttr($value, $data)
    {
        return [
            'province' => Region::getNameById($data['work_province_id']),
            'city' => Region::getNameById($data['work_city_id']),
            'region' => Region::getNameById($data['work_region_id']),
        ];
    }

    /**
     * 地区名称
     * @param $value
     * @param $data
     * @return array
     */
    public function getHomeAttr($value, $data)
    {
        return [
            'province' => Region::getNameById($data['home_province_id']),
            'city' => Region::getNameById($data['home_city_id']),
            'region' => Region::getNameById($data['home_region_id']),
        ];
    }

}
